<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
com.cap.bts.framework.usermgnt.domain.User user = com.cap.bts.commonfunc.common.util.UserUtil.getCurrentUser();
if(user == null){
	response.addHeader("Set-Cookie", "user=" + request.getParameter("dealerNum") + "; path=/; HttpOnly");
}else{
	response.addHeader("Set-Cookie", "user=" + user.getDealerId() + "; path=/; HttpOnly");
}
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>创建客户分组</title>
<%@include file="../include/include.jsp"%>
<script type="text/javascript" src="${jspath}/jquery/jquery-1.8.3.js"></script>
<link rel="stylesheet" type="text/css"
	href="${bootstrapPath}/css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="${csspath }/datepicker.css"/>
<script type="text/javascript" src="${jspath }/ui.datepicker_zh-CN.js"></script>
<script type="text/javascript" src="${jspath }/jquery.ui.min.js"></script>
<script type="text/javascript" src="${bootstrapPath}/js/bootstrap.js"></script> 
<script type="text/javascript" src="${layerPath}/layer.js"></script>
</head>
<style>
* {
    margin: 0px;
    padding: 0px;
    font-family: "Microsoft YaHei";
    color: #000;
}
.icon {
	color: #FFFFFF;
}

.btnLength {
	width: 50px;
}

.checkbox-li {
	display: inline-block;
	width: 100px;
}

.boarder {
	/* //border: 1px solid #DDD; */
}

.text-label {
	width: 130px;
	height: 20px;
	line-height: 20px;
	font-size: 14px;
	font-weight: blod;
	text-align: left;
}

#high10 {
	height: 10px;
}

#high20 {
	height: 20px;
}

#high30 {
	height: 30px;
}

.page_div {
	height: 22px;
	border: 0px solid #F00;
}

.page_div .page_info {
	display: inline-block;
}

.page_div .page_opts {
	float: right;
}

.page_div .page_opts ul {
	list-style: outside none none;
}

#pageNumber2 {
	width: 30px;
}

.page_div .page_opts ul li {
	display: inline-block;
}

.form-control1 {
	width: 100%;
	height: 34px;
	padding: 6px 12px;
	font-size: 14px;
	line-height: 1.42857;
	color: #555;
	background-color: #FFF;
	background-image: none;
	border: 1px solid #CCC;
	border-radius: 0px;
	box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.075) inset;
	transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s
		ease-in-out 0s;
}
</style>
<script type="text/javascript">
	function selectValue(){
		document.getElementById('promotionRadio').value = $("#customPromotion").val();
	}
	$(function() {
		$("#saveSubmit").click(function(){
			$.ajax({
				url : '${webcontext}/crmdp/dealer/remind/saveCustomerPromotion',
				type : 'post',
				data : $('form').serialize(),
				success : function(data) {
					if (data.result) {
						jAlert(data.errorMsg,"提示信息",function(){
							window.location.href = "${webcontext}/crmdp/dealer/remind/toServiceRemind";
						});
					} else {
						jAlert(data.errorMsg,"提示信息");
					}
				},
				error : function(msg) {
					alert("服务器错误，请重试","提示信息");
				}
			})
		});
		$("#viewSubmit").click(function(){
			$.ajax({
				url : '${webcontext}/crmdp/dealer/remind/toSaveCustomerGroup',
				type : 'post',
				data : $('form').serialize(),
				success : function(data) {
					if (data.result) {
						jAlert("保存成功 ","提示信息",function(){
							parent.location.href = "${webcontext}/crmdp/dealer/remind/toServiceRemind";
						});
					} else {
						jAlert(data.errorMsg,"提示信息");
					}
				},
				error : function(msg) {
					alert("服务器错误，请重试","提示信息");
				}
			})
		});
		
		if ($("#sendAllFlag").attr('checked')) {
			$("input[checkall='checkbox']").each(function() {
				$(this).attr('checked', true)
			});
		} else {
			$("input[checkall='checkbox']").each(function() {
				$(this).attr('checked', false)
			});
		}

		$("#sendAllFlag").click(function() {
			if ($("#sendAllFlag").attr('checked')) {
				$("input[checkall='checkbox']").each(function() {
					$(this).attr('checked', true)
				});
			} else {
				$("input[checkall='checkbox']").each(function() {
					$(this).attr('checked', false)
				});
			}
		});

		var isServiceTypeChecked = false;
		$("#search").click(function() {
			layer.load("1");
			$("#search_form").submit();
		});

		$("#submitQuery")
				.click(
						function() {
							jConfirm(
									"确定发送推送信息?",
									"确认提示",
									function(result) {
										if (result == true) {
											layer.load("1");
											$.ajax({
														url : '${webcontext}/crmdp/dealer/remind/sendServiceRemindMsg',
														type : 'post',
														data : $('form')
																.serialize(),
														success : function(data) {
																layer.closeAll("loading");
															if (!data.result) {
																jAlert(data.errorMsg);
															} else {
																jAlert(
																		data.successMsg,
																		"提示",
																		function() {
																			$("form").submit();
																		});
															}
														},
														error : function(msg) {
															alert(msg);
														}
													})
										}
									});
						});

		//选中后该行高亮
		$('tr').bind(
				'click',
				function() {
					if (window.cur)
						window.cur.style.background = "";
					if (window.cur)
						window.cur.style.fontWeight = "normal";
					this.style.background = "#e8e8e8";
					this.style.fontWeight = "bold";
					window.cur = this;
					if ($(this).find("td input[checkall='checkbox']").attr(
							"checked")) {
						$(this).find("td input[checkall='checkbox']").attr(
								"checked", false);
					} else {
						$(this).find("td input[checkall='checkbox']").attr(
								"checked", true);
					}
					return;
				});
		$("td input[checkall='checkbox']").bind('click', function() {
			if ($(this).attr("checked")) {
				$(this).attr("checked", false);
			} else {
				$(this).attr("checked", true);
			}
		})

	});

	function serachBycarPlate(o){
		layer
		.open({
			type : 2,
			offset : [
					'100px',
					'100px' ],
			area : [
					'900px',
					'800px' ],
			scrollbar : false,
			title : '车牌下所有记录',
			content : '${webcontext}/crmdp/dealer/remind/toRemindForCarplate?carPlate=' + encodeURI(encodeURI(o)),
			shadeClose : true,
			end : function() {
			}
		});
	}
	
	function showUserHistory(mobliePhone) {
		layer
		.open({
			type : 2,
			offset : [
					'100px',
					'100px' ],
			area : [
					'900px',
					'800px' ],
			scrollbar : false,
			title : '发送历史',
			content : '${webcontext}/crmdp/dealer/remind/toServiceRemindHistory?mobliePhone=' + encodeURI(encodeURI(mobliePhone)),
			shadeClose : true,
			end : function() {
			}
		});
	}
	
	function newCustomerGroup(){
		layer
		.open({
			type : 2,
			offset : [
					'100px',
					'100px' ],
			area : [
					'900px',
					'800px' ],
			scrollbar : false,
			title : '新建用户分组',
			content : '${webcontext}/crmdp/dealer/remind/toServiceRemindHistory?mobliePhone=' + encodeURI(encodeURI(mobliePhone)),
			shadeClose : true,
			end : function() {
			}
		});
	}
	
	function search() {
		search_form.action = "${webcontext}/crmdp/dealer/remind/toCreateCustomerGroup";
		document.getElementById("search_form").submit();
	}
</script>


<body  style="width: 98%;margin-left: 10px;">
	<form:form id="search_form"
		action="${webcontext}/crmdp/dealer/remind/toCreateCustomerGroup" method="post">
		<input type="hidden" value="" name="qHMobliePhone">
		<div id="high10"></div>
		<div style="margin-left: 25px; width: 900px;">
			<div class="boarder">
				<div id="high10"></div>
				<div class="text-label"
					style="display: inline-block; margin-top: 2px; width: 70px">
					<strong>车型级别 </strong>
				</div>
				<div class=""
					style="display: inline-block; margin-top: 2px; width: 80px">
					<select name="carModel">
						<option value="-1">全部</option>
						<core:forEach items="${srList}" var="serviceRemind">
							<option value="${serviceRemind.carModel}" <core:if test='${dto.carModel == serviceRemind.carModel}'>selected="selected"</core:if>>
								${serviceRemind.carModel}
							</option>
						</core:forEach>
					</select>
				</div>
				<div id="high10"></div>
				<label style="width: 130px"><strong>一年累计进店次数</strong></label>
				<div class=""
					style="display: inline-block; margin-top: 2px">
					<div class="" style="display: inline-block; margin-top: 2px; width: 290px;">
					<input id="fromDate" name="countOfToStoreButtom" value="${dto.countOfToStoreButtom}" style="width: 70px;">
					&nbsp;次&nbsp;-&nbsp;&nbsp;
					<input id="toDate" name="countOfToStoreTop" style="width: 70px;" value="${dto.countOfToStoreTop}">&nbsp;次
				</div>
				</div>
				
				<div class="text-label"
					style="display: inline-block; margin-top: 2px;">
					<label style="width: 130px"><strong>一年内累计消费金额 </strong></label>
				</div>
				<div class="" style="display: inline-block; margin-top: 2px;">
					<input id="fromDate" name="moneyButtom" style="width: 70px;" value="${dto.moneyButtom}">
					&nbsp;元&nbsp;-&nbsp;&nbsp;
					<input id="toDate" name="moneyTop" style="width: 70px;" value="${dto.moneyTop}">&nbsp;元
				</div>
			</div>
			<div>
				<div id="high10"></div>
				<div id="high10"></div>
				<div style="padding-left: 150px;text-align: center;width: 700px;">
					<button id="search" type="button" class="btn btn-success">
						<i class="glyphicon glyphicon-search" style="color: #FFFFFF"></i>&nbsp;查询
					</button>
				</div>
				<div id="high10"></div>
			</div>
			<div id="high10"></div>
		</div>
		<%-- <div style="margin-left: 10px">
			<input type="checkbox" id="sendAllFlag" name="sendAllFlag"
				<core:if test='${dto.sendAllFlag}'>checked</core:if>><strong>全选</strong>
		</div> --%>
		<div class="cantainer">
			<div>
				<table class="table" style="font-size: 80%; width: 100%;">
					<thead>
						<tr>
							<th><nobr>选中</nobr></th>
							<th>姓名</th>
							<th>手机</th>
							<th>车牌</th>
							<th><nobr>最近一年到店次数</nobr></th>
							<th><nobr>最近一年消费金额</nobr></th>
						</tr>
					</thead>
					<tbody>
						<core:forEach items="${list}" var="list" varStatus="status">
							<tr>
								<td><input type="checkbox" checkall="checkbox"
									name="remindList[${status.index}].checkFlag"> <input
									type="hidden" name="remindList[${status.index}].memberId"
									value="${list.memberId }"> <input type="hidden"
									name="remindList[${status.index}].mobliePhone"
									value="${list.mobliePhone }"> <input type="hidden"
									name="remindList[${status.index}].carPlate"
									value="${list.carPlate}"> <input type="hidden"
									name="remindList[${status.index}].nextCalcMileage"
									value="${ list.nextCalcMileage}"> <input type="hidden"
									name="remindList[${status.index}].nextCalcDate"
									value="${ fn: substring (list.nextCalcDate,0,10)}"> <input
									type="hidden" name="remindList[${status.index}].id"
									value="${list.id}"> <input type="hidden"
									name="remindList[${status.index}].remindTimes"
									value="${list.remindTimes}"> <input type="hidden"
									name="remindList[${status.index}].maintenanceItem"
									value="${list.maintenanceItem}"> <input type="hidden"
									name="remindList[${status.index}].lastPartBrand"
									value="${list.lastPartBrand}"></td>
								<td><font>${list.memberName }</font></td>
								<td><font>${list.mobliePhone }</font></td>
								<td>${list.carPlate}</td>
								<td>${list.countOfToStore }</td>
								<td>${list.moneyOfYear }</td>
							</tr>
						</core:forEach>
					</tbody>
				</table>
			</div>
			<div class="page_div">
				<%@include file="../common/page.jsp"%>
			</div>
			<div style="margin-left: 15px;">
				<div class="boarder">
					<div id="high10"></div>
					<div class="text-label"
						style="display: inline-block; margin-top: 2px;width: 100px;">
						<label style="width: 130px"><strong>客户类型 </strong></label>
					</div>
					<div class="" style="display: inline-block; margin-top: 2px;">
						<input type="text" name="groupName" style="">
						<button type="button" id="viewSubmit" class="btn btn-success btn-xs" style="margin-left: 20px;">
							<i class="glyphicon glyphicon-upload" style="color: #FFFFFF"></i>&nbsp;保&nbsp;&nbsp;存&nbsp;
						</button>&nbsp;
					</div>
				</div>
			</div>
		</div>
	</form:form>
</body>
</html>